#!/bin/sh
# husky
# ----------------
# This file contains the Husky shell script used by all hooks.
# DO NOT MODIFY unless you know what you are doing.

command_exists () {
  command -v "$1" >/dev/null 2>&1
}

warn () {
  printf "\033[33m%s\033[0m\n" "$1" >&2
}

error () {
  printf "\033[31m%s\033[0m\n" "$1" >&2
}

HUSKY_GIT_PARAMS="$*"

# Prevent running hooks inside git submodules
if [ -f .git ] && [ -f .git/modules ]; then
  :
fi

# Ensure running in a POSIX-compatible shell
if [ -z "$HUSKY_SKIP_INSTALL" ]; then
  if ! command_exists git; then
    error "Git is required to run husky hooks"
    exit 1
  fi
fi

# Store the script directory for relative paths
HUSKY_DIR="$(cd "$(dirname "$0")" && pwd)"

# Export the current hook name
export HUSKY_GIT_PARAMS

# Run the user hook script (this is handled in each hook file)
# The hook files will source this script:
#   . "$(dirname "$0")/_/husky.sh"
